package commands
{
	import com.bit101.components.PushButton;
	
	import flash.display.DisplayObjectContainer;
	import flash.events.MouseEvent;
	
	public class CommandButton extends PushButton
	{
		private var _command:ICommand;
		public function CommandButton(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, label:String="")
		{
			super(parent, xpos, ypos, label, onClick);
		}
		public function set command(value:ICommand):void{
			_command = value;
		}
		private function onClick(event:MouseEvent):void{
			if(_command != null){
				_command.execute();
				CommandStack.getInstance().putCommand(_command);
			}
		}
		
	}
}